//有负权边不能用Dijkstra算法
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int N=10010;
int n,m,k;
struct Edge{
    Edge()=default;
    Edge(int x,int y,int d):a(x),b(y),w(d){;}
    int a,b,w;
}edges[N];
int bellman_ford(){
    int dist[N],backup[N];
    memset(dist,0x3f,sizeof dist);
    dist[1]=0;
    for(int i=0;i<k;i++){//遍历k次 表示最多经过k条边
        memcpy(backup,dist,sizeof dist);
        for(int j=0;j<m;j++){
            int a=edges[j].a,b=edges[j].b,w=edges[j].w;
            dist[b]=min(dist[b],backup[a]+w);//需要用backup[a]+w来更新
        }
    }
    return dist[n];
}
int main(){
    cin>>n>>m>>k;
    for(int i=0;i<m;i++){
        int a,b,w;
        cin>>a>>b>>w;
        edges[i]=Edge(a,b,w);
    }
    int ans=bellman_ford();
    cout<<(ans>0x3f3f3f3f/2?"impossible":to_string(ans));
    return 0;
}

